nums = [1, 2, 3, 4, 5, 6, 7], k = 3
nums = [1, 2], k = 5

var rotate = function (nums, k) {
    let len = nums.length
    while (len < k) {
        k = k % len
    }
    let mid = nums.splice(len - k, k)
    nums.unshift(...mid)
    return nums
};
console.log(rotate(nums, k));
